package com.kingwood.algorithm.test;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author 22025812
 * @Description: 求最多可以派出多少支团队
 * https://fcqian.blog.csdn.net/article/details/127418310
 * @Date: 2024/3/28 10:19
 * @Modified By：
 * @Version 1.0
 */
public class MaxNumberOfTeam {

    public static int getResult(int[] arr, int k) {
        int ans = 0;
        Arrays.sort(arr);

        int l = 0;
        int r = arr.length - 1;

        while (l <= r && arr[r] >= k) {
            ans++;
            r--;
        }

        while (l < r) {
            if (arr[l] + arr[r] >= k) {
                ans++;
                l++;
                r--;
            } else {
                l++;
            }
        }

        return ans;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        int arr[] = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int k = Integer.parseInt(scanner.nextLine());

        System.out.println(getResult(arr, k));
    }
}
